package com.admin.business.portalWebsite.venusSysActivityReclect;

import com.tiangong.framework.annotation.OpenApi;
import com.tiangong.framework.bo.CDO;
import com.tiangong.framework.bo.Return;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * @description: 活动提现记录表
 * @create: 2023-11-21 14:18:29
 **/
@Service("venusSysActivityReclectService")
@Slf4j
public class VenusSysActivityReclectService{

    @Resource
    VenusSysActivityReclectDao venusSysActivityReclectDao;

    /**
     * 添加活动体现记录表,获取id数据
     *
     * @param cdoRequest - id:主键
     *                   - user_id:用户id
     *                   - activity_id:活动id
     *                   - activity_total_money:共计金额
     *                   - activity_actual_money:实际体现金额
     *                   - collection_person:收款人
     *                   - bank_deposit:开户行
     *                   - card_number:账号
     *                   - payment_images:打款凭证
     *                   - update_time:更新时间
     *                   - begin_time:创建时间
     *                   - state:是否删除：0、审核中，1、已审核；
     * @return
     * @author wdf
     * @create: 2023-11-21 14:18:29
     */
    @OpenApi
    public Return addVenusSysActivityReclect(CDO cdoRequest) {
        venusSysActivityReclectDao.addVenusSysActivityReclect(cdoRequest);
        CDO cdoResult = new CDO();
        if (cdoRequest.containsKey("id")) {
            cdoResult.set("id", cdoRequest.get("id"));
        }
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据id，更新活动体现记录表数据
     *
     * @param cdoRequest - id:主键
     *                   - user_id:用户id
     *                   - activity_id:活动id
     *                   - activity_total_money:共计金额
     *                   - activity_actual_money:实际体现金额
     *                   - collection_person:收款人
     *                   - bank_deposit:开户行
     *                   - card_number:账号
     *                   - payment_images:打款凭证
     *                   - update_time:更新时间
     *                   - begin_time:创建时间
     *                   - state:是否删除：0、审核中，1、已审核；
     * @return
     * @author wdf
     * @create: 2023-11-21 14:18:29
     */
    @OpenApi
    public Return updateVenusSysActivityReclectById(CDO cdoRequest) {
        venusSysActivityReclectDao.updateVenusSysActivityReclectById(cdoRequest);
        return Return.SUCCESS;
    }

    /**
     * 根据id，删除活动体现记录表数据
     *
     * @param cdoRequest - id:主键
     * @return
     * @author wdf
     * @create: 2023-11-21 14:18:29
     */
    @OpenApi
    public Return deleteVenusSysActivityReclectById(CDO cdoRequest){
        int count = venusSysActivityReclectDao.deleteVenusSysActivityReclectById(cdoRequest.getLong("id"));
        CDO cdoResult = new CDO();
        cdoResult.set("count", count);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据条件，删除活动体现记录表数据
     *
     * @param cdoRequest
     * @return
     * @author wdf
     * @create: 2023-11-21 14:18:29
     */
    @OpenApi
    public Return deleteVenusSysActivityReclect(CDO cdoRequest) {
        int count = venusSysActivityReclectDao.deleteVenusSysActivityReclect(cdoRequest);
        CDO cdoResult = new CDO();
        cdoResult.set("count", count);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据ID，获取活动体现记录表数据
     *
     * @param cdoRequest - id:主键
     * @return
     * @author wdf
     * @create: 2023-11-21 14:18:29
     */
    @OpenApi
    public Return getVenusSysActivityReclectById(CDO cdoRequest) {
        CDO cdoMapperResult = venusSysActivityReclectDao.getVenusSysActivityReclectById(cdoRequest.getLong("id"));
        return Return.valueOf(cdoMapperResult);
    }

    /**
     * 根据非空条件，获取活动体现记录表数据列表
     *
     * @param cdoRequest
     * @return
     * @author wdf
     * @create: 2023-11-21 14:18:29
     */
    @OpenApi
    public Return getVenusSysActivityReclectListPage(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.getInteger("pageIndex")-1;
        int recordSize = 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusSysActivityReclectDao.getVenusSysActivityReclectListPage(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
//        int total = venusSysActivityReclectDao.getVenusSysActivityReclectCount(cdoRequest);
//        cdoResult.set("total", total);
        return Return.valueOf(cdoResult);
    }
    /**
     * 根据混合条件，获取活动体现记录表数据列表
     *
     * @param cdoRequest - id:主键
     * @return
     * @author wdf
     * @create: 2023-11-21 14:18:29
     */
    @OpenApi
    public Return getVenusSysActivityReclectListPageByCondition(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.getInteger("pageIndex")-1;
        int recordSize = 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusSysActivityReclectDao.getVenusSysActivityReclectListPageByCondition(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
//        int total = venusSysActivityReclectDao.getVenusSysActivityReclectCount(cdoRequest);
//        cdoResult.set("total", total);
        return Return.valueOf(cdoResult);
    }
}
